home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Development / Source / MSG Graphic Effects 1.0 Source / Circle in.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-08-23  |  2.4 KB  |  74 lines  |  [TEXT/KAHL]

  1. /*******************************************************************************
  2.  * Copyright © 1992-1993 Mark Pilgrim                                          *
  3.  *                                                                             *
  4.  * This file is provided as is, and may be freely distributed unaltered.  This *
  5.  * message must accompany any copy of this file.  This file may be used or     *
  6.  * modified for use for a non-commercial product provided that appropriate     *
  7.  * credit is given to the author named above.                                  *
  8.  * Commercial use of this source code is prohibited.                           *
  9.  ******************************************************************************/
  10.  
  11. #include "msg misc.h"
  12. #include "msg timing.h"
  13.  
  14. #define    gap            4        /* difference between one radius and the next */
  15. #define    StartRadius    300        /* should be just over || (cx,cy) || */
  16. #define CorrectTime 2
  17.  
  18. void CircleIn(GrafPtr);
  19.  
  20. /* Take a really big circle, then a slightly smaller circle (-gap), then
  21.    take the region in between them and copy that, then decrease the outer
  22.    circle radius by gap.  Thus: circle in, by successive donut-like copies. */
  23.  
  24. void CircleIn(GrafPtr sourceGrafPtr)
  25. {
  26.     Rect        theRect;
  27.     Rect        source;
  28.     int            cx, cy;
  29.     RgnHandle    curregion,lastregion,diffregion;
  30.     
  31.     cx = MAIN_WINDOW_WIDTH / 2;
  32.     cy = MAIN_WINDOW_HEIGHT / 2;
  33.     
  34.     theRect.left=cx-StartRadius;     /* circumscribing rectangle for outer circle */
  35.     theRect.right=cx+StartRadius;
  36.     theRect.top=cy-StartRadius;
  37.     theRect.bottom=cy+StartRadius;
  38.     
  39.     source.top=source.left=0;
  40.     source.bottom=MAIN_WINDOW_HEIGHT;
  41.     source.right=MAIN_WINDOW_WIDTH;
  42.     
  43.     curregion=NewRgn();
  44.     lastregion=NewRgn();
  45.     diffregion=NewRgn();
  46.  
  47.     SetEmptyRgn(lastregion);
  48.     OpenRgn();
  49.         FrameOval(&theRect);        /* first circle */
  50.     CloseRgn(lastregion);
  51.     
  52.     while (theRect.right-theRect.left>0)
  53.     {
  54.         StartTiming();
  55.         theRect.left+=gap;
  56.         theRect.right-=gap;
  57.         theRect.top+=gap;
  58.         theRect.bottom-=gap;
  59.         SetEmptyRgn(curregion);
  60.         OpenRgn();
  61.             FrameOval(&theRect);   /* inner circle */
  62.         CloseRgn(curregion);
  63.         DiffRgn(lastregion,curregion,diffregion);   /* donut we need */
  64.         CopyBits(&(sourceGrafPtr->portBits), &(gMainWindow->portBits),
  65.                 &source, &source, 0, diffregion);
  66.         CopyRgn(curregion,lastregion);    /* outer circle = inner circle */
  67.         TimeCorrection(CorrectTime);
  68.     }
  69.     
  70.     DisposeRgn(curregion);
  71.     DisposeRgn(lastregion);
  72.     DisposeRgn(diffregion);
  73. }
  74.